package com.demo.server.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.demo.server.entity.Log;
import com.demo.server.entity.req.LogSearchReq;
import com.demo.server.service.LogService;
import com.demo.server.util.Result;
import com.demo.server.util.ResultPage;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Controller
@RequestMapping("log")
@Tag(name="操作日志")
public class LogController {

	@Autowired
	LogService logService;
	
	@PostMapping("search")
    @ResponseBody
    @Operation(summary = "查询操作日志")
	@Parameter(name="token",description = "token",required = true,in = ParameterIn.HEADER)
	public ResultPage<Log> search(@RequestBody LogSearchReq req){
		log.info("search>>:{}",req);
		return logService.search(req);
	}
	
	@PostMapping("clear")
    @ResponseBody
    @Operation(summary = "清空操作日志")
	@Parameter(name="token",description = "token",required = true,in = ParameterIn.HEADER)
	public Result clear(){
		log.info("clear>>");
		return logService.clear();
	}
}
